home *** CD-ROM | disk | FTP | other *** search
- /*
- * 'union word' must be the size necessary to ensure that an sbrk()
- * immediately following an sbrk(sizeof(union word) * n) returns an
- * address one higher than the first sbrk. i.e. contiguous space from
- * successive sbrks. This is not vital - the malloc will work, but will
- * not be able to coalesce between sbrk'ed segments. What is more often
- * vital is that the things you use the malloc for, like pointers,
- * structs etc. may need to be aligned on a word/long-word/double-word
- * boundary depending on the machine. This is the job of the 'foo'
- * field in the union, which actually decides the size. (On Sun3s, 1
- * int/long (4 bytes) is good enough, on Sun4s, 8 bytes are necessary,
- * i.e. 2 ints/longs)
- */
- /* Good enough for all machines I use. Change it for your favourite box */
- /* need 2 for Sun4s, 1 for Sun3s. */
- #if defined(m68k) || defined(mc68000) || defined(vax)
- #define ALIGN long foo
- #define NALIGN 4
- #endif /* m68k || mc68000 || vax */
-
- #ifdef sparc
- #define ALIGN long foo[2]
- #define NALIGN 8
- #endif
-
- #ifndef ALIGN
- You must fix ALIGN before proceeding.
- #endif
-
- /* Align with power of 2 */
- #define SIMPLEALIGN(X, N) (char *)(((u_long)((char *)(X) + (N-1))) & ~(N-1))
-
- #if NALIGN == 2 || NALIGN == 4 || NALIGN == 8 || NALIGN == 16
- /* if NALIGN is a power of 2, the next line will do ok */
- #define ALIGNPTR(X) SIMPLEALIGN(X, NALIGN)
- #else
- /* otherwise we need the generic version; hope the compiler isn't too smart */
- static int nalign = NALIGN;
- #define ALIGNPTR(X) (char *)((((u_long)((char *)(X) + (NALIGN-1)))/nalign)*nalign)
- #endif
-
- /*
- * Does sbrk return blocks that are aligned with ALIGN? If not, define
- * this. I know Suns sbrk() returns aligned stuff. Don't know about
- * others.
- */
- #ifndef sun
- #define SBRKUNALIGNED
- #endif /* !sun */
-